package main

import (
	"fmt"
	"reflect"
)

/*
* Author: JacksonCoder
* CreateTime: 2025/5/20
 */

type SkillsService interface{
	Reading()
	Running()
}

type Stu struct{
	Name string
	Age int
}

func (self Stu) Running() {
	fmt.Printf("%s is Running\n", self.Name)
}
func (self Stu) Reading() {
	fmt.Printf("%s is Reading\n", self.Name)
}

func main() {
	stu1 := Stu{Name: "darren", Age: 18}
	stu_val := reflect.ValueOf(stu1)                //获取Value类型
	fmt.Println(stu_val.NumField())                 //2
	fmt.Println(stu_val.Field(0), stu_val.Field(1)) //darren 18
	fmt.Println(stu_val.FieldByName("Age"))         //18

	stu_val2 := reflect.ValueOf(&stu1).Elem() // 要修改传引用或者指针
	stu_val2.FieldByName("Age").SetInt(33)    //设置字段值 ，结果33
	fmt.Println(stu1.Age)

}